package com.xinzhi.service.impl;

import com.xinzhi.mapper.BankaccountMapper;
import com.xinzhi.pojo.Bankaccount;
import com.xinzhi.service.IBankaccountService;
import com.xinzhi.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BankaccountServiceImpl implements IBankaccountService {
    @Autowired
    private BankaccountMapper bankaccountMapper;
    @Override
    public Result selectMoney(String cardNumber) {
        if (cardNumber == null)
            return Result.error("参数不能为空");
        // 查询余额
        Bankaccount bankaccount = bankaccountMapper.selectMoney(cardNumber);
        return bankaccount!=null ? Result.ok(bankaccount):Result.error("查询失败");
    }

    /**
     * 根据手机号查询用户信息
     * @param phone_number
     * @return
     */
    @Override
    public Result selectBank(String phone_number) {
        Bankaccount bankaccount = bankaccountMapper.selectBankaccount(phone_number);
        return bankaccount!=null ?Result.ok(bankaccount):Result.error("400");
    }

    @Override
    public Result selectPassword(String card_number, String card_password) {
        Bankaccount bankaccount = bankaccountMapper.selectPassword(card_number, card_password);
        return bankaccount!=null ?Result.ok("验证成功"):Result.error("验证失败");
    }
}
